﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace EasierRdp.Base
{
    abstract class RdpModel : INode
    {
        public int Id { get; set; }

        public string Name { get; set; }

        public abstract IEnumerable<INode> Children { get; }

        public bool Expanded { get; set; }

        public const string
            AttributeExpanded = "Expanded",
            AttributeName = "Name",
            AttributeId = "Id";

        public abstract XElement ToXml();

        public override string ToString()
        {
            return Name;
        }

        public static bool operator == (RdpModel item1, RdpModel item2)
        {
            if ((object) item1 == null )
            {
                return (object) item2 == null;
            }
            return (object) item2 != null && item1.Id == item2.Id;
        }

        public static bool operator !=(RdpModel item1, RdpModel item2)
        {
            return !(item1 == item2);
        }
        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            if (obj.GetType() != this.GetType()) return false;
            return Id == ((RdpModel)obj).Id;
        }

        public override int GetHashCode()
        {
            return Id;
        }

    }
}
